<template>
	<view class="wrap">
		<view class="banner">
			<image src="../../static/zichanbannerbg.png"></image>
			<view class="title">
				总资产
			</view>
			<view class="number">
				{{dataObj.balance}}
			</view>
		</view>
		
		
		<view class="address">
			<view class="title">
				提现金额 
			</view>
			<view class="ipt-wrap">
				<input v-model="amount" type="text" placeholder="输入您的提现金额" />
				<view class="btn-amount" @click="getAll">
					全部提现
				</view>
			</view>
			
		</view>
		<view class="address-">
			<view class="bold-t">
				最多可以提现<text class="btn-amount">
					{{dataObj.balance}}
				</text>   
			</view>
			<!-- <view class="title">
				备注（选填）
			</view>
			<view class="ipt-wrap">
				<input v-model="remark" type="text" placeholder="仅在交易明细展示" />
				
			</view> -->
			
		</view>

		<view class="tip">
			
			<view class="item-line" v-for="(item,index) in instruction" :key="index">
				
				{{item}}
				

			</view>
			
		
		</view>
		<view class="subdata" @click="topay">
			{{type=='创富收益'?"申请出场":'确认提现'}}
		</view>
		<paypass ref="yspay" @cancel="cancelpay" @submit="submitpay"></paypass>
	</view>
</template>

<script>
	import paypass from "@/components/ys-paypass/ys-paypass.vue";
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	export default {
		components:{
			paypass,
			tkiQrcode
		},
		data() {
			return {
				
				remark:'',
				ifShow: true,
				instruction:[],
				amount:'',
				address:'',
				type:'',
				dataObj:{}
			}
		},
		onShow(){
			//this.getData()
		},
		onLoad(options) {
			this.type=options.type=='USDT'?'USD':options.type
			uni.setNavigationBarTitle({
			    title: options.type=='USDT'?'USD':options.type
			});
			this.getData()
		},
		onNavigationBarButtonTap:function(e){
			
			let type=this.type=='USD'?'USDT':this.type
			if(type==='合伙人收益'){
				uni.navigateTo({
					url: `../bizhongmingxinew/index?type=${type}`
				});
			}else{
				uni.navigateTo({
					url: `../chanchumingxierji/index?name=创富`
				});
			}
			
		               
		 },
		methods: {

			getAll(){
				
				
				this.amount=this.dataObj.balance
			},
			topay(){
				
				if(this.amount===''){
					uni.showToast({
					    title: '输入提现数量',
					    dduration:4000,
						icon:'none'
					});
					return
				}
				if(this.amount>this.dataObj.balance){
					uni.showToast({
					    title: '超出最大提现数量',
					    dduration:4000,
						icon:'none',
					
					});
					return
				}
				
				this.$refs.yspay.show();
			},
			cancelpay(){
				
			},
			submitpay(ex){
				this.subData(ex.value)
			},
			subchuangfu(pwd){
				let that=this
				that.apipost('/api/assets/wealth_extract',{
					
					amount:that.amount,
					pwd
				},true).then(res => {
					if(res.Code==10200){
						uni.showToast({
							title: res.Message,
							duration:4000,
							icon: 'none'
						});
						uni.navigateBack()
						
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			subhehuo(pwd){
				let that=this
				that.apipost('/api/assets/partner_extract',{
					
					amount:that.amount,
					pwd
				},true).then(res => {
					if(res.Code==10200){
						uni.showToast({
							title: res.Message,
							duration:4000,
							icon: 'none'
						});
						uni.navigateBack()
						
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			subData(pwd){
				let that=this
				uni.showModal({
				    title: '确认提交？',
				    content: '',
				    success: function (res) {
				        if (res.confirm) {
							if(that.type==='合伙人收益'){
								that.subhehuo(pwd)
							}else{
								that.subchuangfu(pwd)
							}
				            
				        } else if (res.cancel) {
				            
				        }
				    }
				});
			},
			copy(){
				
				let that=this
				uni.setClipboardData({
					data: that.dataObj.charge_address, //要被复制的内容
					success: function() {
						
						uni.showToast({
							title: '复制成功',
							duration:4000,
							icon: 'none'
						});
					},
					fail: function(err) {
						
						uni.showToast({
							title: '复制失败',
							duration:4000,
							icon: 'none'
						});
					}
			});
			},
		
			getData(){
				let that=this
				
				that.apipost('/api/assets/currency_details',{
					currency:that.type=='USD'?'USDT':that.type
				},true).then(res => {
					if(res.Code==10200){
						
						let data=res.Data?res.Data:{}
						that.instruction=data.instruction
						that.dataObj=res.Data?res.Data:{}
						that.val=that.dataObj.charge_address
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},

			enterpage(path){
				if(path){
					uni.navigateTo({
					    url: path
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			}
		}
	}
</script>

<style>
	.subdata{
		width:616rpx;
		height:90rpx;
		display:flex;
		align-items: center;
		justify-content: center;
		color:#fff;
		background:#007aff;
		border-radius:10rpx;
		margin:30rpx auto;
	}
	.copy-wrap uni-image{
		width:44rpx;
		height:44rpx;
	}
	.copy-wrap{
		display:flex;
		align-items: center;
		width:100px;
		margin:0 auto;
		color:#b3b3b3;
	}
	.address-wenzi{
		color:#7d7d7f;
		font-size:26rpx;
		text-align:center;
	}
	.chongzhi-wrap .img-erweima{
		display:flex;
		justify-content: center;
		align-items: center;
		width:488rpx;
		height:488rpx;
		margin:0 auto;
		margin-top:16rpx;
		margin-bottom:16rpx;
	}
	.chongzhi-wrap .title{
		color:#7d7d7f;
		text-align:center;
	}
	.tip .item-line{
		padding-top:8rpx;
	}
	.address .bold-t{
		padding-top:10rpx;
		font-size:28rpx;
		color:#515151;
	}
	.address .btn-amount{
		width:190rpx;
		color:#fe6700;
	}
	.address .btn{
		height:40rpx;
		width:40rpx;
		background:url(../../static/copybtn.png) no-repeat;
		background-size:100% 100%;
	}
	.ipt-wrap{
		flex:1;
		display:flex;
		justify-content: space-between;
	}
	.tip{
		width:600rpx;
		margin:0 auto;
		color:#86858a;
		margin-top:46rpx;
	}
	.address{
		width:600rpx;
		margin:0 auto;
		margin-top:100rpx;
		border-bottom:1rpx solid #e7e7e9;
	}
	.address-{
		width:600rpx;
		margin:0 auto;
		margin-top:8rpx;
		
	}
	.address- .btn-amount{
		
		color:#fe6700;
	}
	.address .ipt-wrap{
		height:82rpx;
		display:flex;
		align-items: center;
	}
	.address .title{
		padding:26rpx 0 8rpx 0;
		font-size:34rpx;
	}
	.tab-wrap .item{
		color:#747476;
		height:100%;
		display:flex;
		box-sizing: border-box;
		align-items: center;
		justify-content: center;
		border-bottom:5rpx solid #fff;
	}
	.tab-wrap .active{
		color:#000;
		border-bottom:4rpx solid #1c74d6;
	}
	.tab-wrap{
		width:740rpx;
		margin:0 auto;
		margin-top:16rpx;
		margin-bottom:48rpx;
		border-bottom:1rpx solid #dfdfdf;
		height:112rpx;
		display:flex;
		justify-content: space-around;
		align-items: center;
	}
	page{
		background:#fff;
		border-top:1rpx solid #e6e6e6;
	}
	.banner{
		color:#fff;
		
		width:692rpx;
		height:180rpx;
		position:relative;
		margin:0 auto;
		border-radius:8rpx;
	}
	.banner .title{
		position:absolute;
		top:40rpx;
		left:42rpx;
		
	}
	.banner .number{
		font-size:38rpx;
		position:absolute;
		top:90rpx;
		left:42rpx;
	}
	.wrap{
		padding:24rpx 0;
	}
	.ipt-wrap input{
		flex:1;
		font-size:26rpx;
	}
</style>
